---
title: "-="
root: "/v5.1"
layout: "default"
description: "Swift documentation for '-='"
keywords: ""
---

<div class="intro-declaration"><code class="language-swift">func -=(lhs:rhs:)(lhs: inout Int, rhs: Int)</code></div><div class="discussion comment"><p>Subtracts the second value from the first and stores the difference in the
left-hand-side variable.
</p>
<p>The difference of the two arguments must be representable in the
arguments' type. In the following example, the result of <code>21 - 50</code> is
less than zero, the minimum representable <code>UInt8</code> value:</p>
<pre><code class="language-swift">var x: UInt8 = 21
x - 50
// Overflow error
</code></pre>
<blockquote>
<p>Note:
Overflow checking is not performed in <code>-Ounchecked</code> builds.</p>
</blockquote>
</div><div class="intro-declaration"><code class="language-swift">func -=(lhs:rhs:)(lhs: inout Int16, rhs: Int16)</code></div><div class="discussion comment"><p>Subtracts the second value from the first and stores the difference in the
left-hand-side variable.
</p>
<p>The difference of the two arguments must be representable in the
arguments' type. In the following example, the result of <code>21 - 50</code> is
less than zero, the minimum representable <code>UInt8</code> value:</p>
<pre><code class="language-swift">var x: UInt8 = 21
x - 50
// Overflow error
</code></pre>
<blockquote>
<p>Note:
Overflow checking is not performed in <code>-Ounchecked</code> builds.</p>
</blockquote>
</div><div class="intro-declaration"><code class="language-swift">func -=(lhs:rhs:)(lhs: inout Int32, rhs: Int32)</code></div><div class="discussion comment"><p>Subtracts the second value from the first and stores the difference in the
left-hand-side variable.
</p>
<p>The difference of the two arguments must be representable in the
arguments' type. In the following example, the result of <code>21 - 50</code> is
less than zero, the minimum representable <code>UInt8</code> value:</p>
<pre><code class="language-swift">var x: UInt8 = 21
x - 50
// Overflow error
</code></pre>
<blockquote>
<p>Note:
Overflow checking is not performed in <code>-Ounchecked</code> builds.</p>
</blockquote>
</div><div class="intro-declaration"><code class="language-swift">func -=(lhs:rhs:)(lhs: inout Int64, rhs: Int64)</code></div><div class="discussion comment"><p>Subtracts the second value from the first and stores the difference in the
left-hand-side variable.
</p>
<p>The difference of the two arguments must be representable in the
arguments' type. In the following example, the result of <code>21 - 50</code> is
less than zero, the minimum representable <code>UInt8</code> value:</p>
<pre><code class="language-swift">var x: UInt8 = 21
x - 50
// Overflow error
</code></pre>
<blockquote>
<p>Note:
Overflow checking is not performed in <code>-Ounchecked</code> builds.</p>
</blockquote>
</div><div class="intro-declaration"><code class="language-swift">func -=(lhs:rhs:)(lhs: inout Int8, rhs: Int8)</code></div><div class="discussion comment"><p>Subtracts the second value from the first and stores the difference in the
left-hand-side variable.
</p>
<p>The difference of the two arguments must be representable in the
arguments' type. In the following example, the result of <code>21 - 50</code> is
less than zero, the minimum representable <code>UInt8</code> value:</p>
<pre><code class="language-swift">var x: UInt8 = 21
x - 50
// Overflow error
</code></pre>
<blockquote>
<p>Note:
Overflow checking is not performed in <code>-Ounchecked</code> builds.</p>
</blockquote>
</div><div class="intro-declaration"><code class="language-swift">func -=(lhs:rhs:)(lhs: inout UInt, rhs: UInt)</code></div><div class="discussion comment"><p>Subtracts the second value from the first and stores the difference in the
left-hand-side variable.
</p>
<p>The difference of the two arguments must be representable in the
arguments' type. In the following example, the result of <code>21 - 50</code> is
less than zero, the minimum representable <code>UInt8</code> value:</p>
<pre><code class="language-swift">var x: UInt8 = 21
x - 50
// Overflow error
</code></pre>
<blockquote>
<p>Note:
Overflow checking is not performed in <code>-Ounchecked</code> builds.</p>
</blockquote>
</div><div class="intro-declaration"><code class="language-swift">func -=(lhs:rhs:)(lhs: inout UInt16, rhs: UInt16)</code></div><div class="discussion comment"><p>Subtracts the second value from the first and stores the difference in the
left-hand-side variable.
</p>
<p>The difference of the two arguments must be representable in the
arguments' type. In the following example, the result of <code>21 - 50</code> is
less than zero, the minimum representable <code>UInt8</code> value:</p>
<pre><code class="language-swift">var x: UInt8 = 21
x - 50
// Overflow error
</code></pre>
<blockquote>
<p>Note:
Overflow checking is not performed in <code>-Ounchecked</code> builds.</p>
</blockquote>
</div><div class="intro-declaration"><code class="language-swift">func -=(lhs:rhs:)(lhs: inout UInt32, rhs: UInt32)</code></div><div class="discussion comment"><p>Subtracts the second value from the first and stores the difference in the
left-hand-side variable.
</p>
<p>The difference of the two arguments must be representable in the
arguments' type. In the following example, the result of <code>21 - 50</code> is
less than zero, the minimum representable <code>UInt8</code> value:</p>
<pre><code class="language-swift">var x: UInt8 = 21
x - 50
// Overflow error
</code></pre>
<blockquote>
<p>Note:
Overflow checking is not performed in <code>-Ounchecked</code> builds.</p>
</blockquote>
</div><div class="intro-declaration"><code class="language-swift">func -=(lhs:rhs:)(lhs: inout UInt64, rhs: UInt64)</code></div><div class="discussion comment"><p>Subtracts the second value from the first and stores the difference in the
left-hand-side variable.
</p>
<p>The difference of the two arguments must be representable in the
arguments' type. In the following example, the result of <code>21 - 50</code> is
less than zero, the minimum representable <code>UInt8</code> value:</p>
<pre><code class="language-swift">var x: UInt8 = 21
x - 50
// Overflow error
</code></pre>
<blockquote>
<p>Note:
Overflow checking is not performed in <code>-Ounchecked</code> builds.</p>
</blockquote>
</div><div class="intro-declaration"><code class="language-swift">func -=(lhs:rhs:)(lhs: inout UInt8, rhs: UInt8)</code></div><div class="discussion comment"><p>Subtracts the second value from the first and stores the difference in the
left-hand-side variable.
</p>
<p>The difference of the two arguments must be representable in the
arguments' type. In the following example, the result of <code>21 - 50</code> is
less than zero, the minimum representable <code>UInt8</code> value:</p>
<pre><code class="language-swift">var x: UInt8 = 21
x - 50
// Overflow error
</code></pre>
<blockquote>
<p>Note:
Overflow checking is not performed in <code>-Ounchecked</code> builds.</p>
</blockquote>
</div>